#!/bin/bash

tmux has-session -t redis
if [ $? != 0 ]; then
    tmux new-session -s redis -n sources -d
    tmux send-keys -t redis 'cd /opt/sources/redis-6.2.6/src' C-m
    tmux send-keys -t redis 'vim server.c' C-m
    tmux new-window -n ranger -t redis
    tmux send-keys -t redis:2 'cd /opt/sources/redis-6.2.6' C-m
    tmux send-keys -t redis:2 'ranger .' C-m
    tmux select-window -t redis:1
fi

if [ -z "$TMUX" ]; then
    tmux -u attach-session -t redis
else
    tmux -u switch-client -t redis
fi
